import req from '@/http/http'
import config from '@/config/index'

// zhpq接口
const ZHPQ_SERVER = config.serverUrl()

export const getServer = _ => {
  return ZHPQ_SERVER
}

// 案件
const CLIENT_CREATE_PATH = ZHPQ_SERVER + '/lawClient/'
const CLIENT_PUT_PATH = ZHPQ_SERVER + '/lawClient'
const CASE_CREATE_PATH = ZHPQ_SERVER + '/lawCase/'
const CASE_GET_PATH = ZHPQ_SERVER + '/lawCase'
const DEFENDANTUNIT_POST_PATH = ZHPQ_SERVER + '/caseDefendantUnit/'
const DEFENDANTUNIT_GET_PATH = ZHPQ_SERVER + '/caseDefendantUnit'
const DEFENDANTPERSON_GET_PATH = ZHPQ_SERVER + '/caseDefendantPerson'
const DEFENDANTPERSON_POST_PATH = ZHPQ_SERVER + '/caseDefendantPerson/'
const PLAINTIFFTPERSON_POST_PATH = ZHPQ_SERVER + '/casePlaintiffPerson/'
const PLAINTIFFTPERSON_GET_PATH = ZHPQ_SERVER + '/casePlaintiffPerson'
const PLAINTIFFTCOMPANY_POST_PATH = ZHPQ_SERVER + '/casePlaintiffUnit/'
const PLAINTIFFTCOMPANY_GET_PATH = ZHPQ_SERVER + '/casePlaintiffUnit'

// 委托人添加
export const createClient = data => {
  return req.post(CLIENT_CREATE_PATH, data)
}
// 委托人修改
export const putClient = data => {
  let path = CLIENT_PUT_PATH + '/' + data.id
  return req.put(path, data)
}
// 事件添加
export const createLawCase = data => {
  return req.post(CASE_CREATE_PATH, data)
}
// 事件获取
export const getLawCase = data => {
  return req.get(CASE_GET_PATH, data)
}
// 事件获取by   id
export const getLawCaseDetail = id => {
  let path = CASE_GET_PATH + '/' + id
  return req.get(path)
}
// 事件修改
export const putLawCase = data => {
  let path = CASE_GET_PATH + '/' + data.id
  return req.put(path, data)
}
// 事件删除
export const delLawCase = id => {
  let path = CASE_GET_PATH + '/' + id
  return req.delete(path)
}
// 被告单位添加
export const createDefendantUnit = data => {
  return req.post(DEFENDANTUNIT_POST_PATH, data)
}
// 被告单位修改
export const putDefendantUnit = data => {
  let path = DEFENDANTUNIT_GET_PATH + '/' + data.id
  return req.put(path, data)
}
// 被告个人添加
export const postDefendantPerson = data => {
  return req.post(DEFENDANTPERSON_POST_PATH, data)
}
// 被告个人获取
export const getDefendantPerson = data => {
  return req.get(DEFENDANTPERSON_GET_PATH, data)
}
// 被告个人修改
export const putDefendantPersonReq = data => {
  let path = DEFENDANTPERSON_GET_PATH + '/' + data.id
  return req.put(path, data)
}
// 原告个人添加
export const postPlaintiffPerson = data => {
  return req.post(PLAINTIFFTPERSON_POST_PATH, data)
}
// 原告个人获取
export const getPlaintiffPerson = id => {
  let path = PLAINTIFFTPERSON_GET_PATH + '/' + id
  return req.get(path)
}
// 原告个人修改
export const putPlaintiffPersonReq = data => {
  let path = PLAINTIFFTPERSON_GET_PATH + '/' + data.id
  return req.put(path, data)
}
// 原告单位添加
export const postPlaintiffCompany = data => {
  return req.post(PLAINTIFFTCOMPANY_POST_PATH, data)
}
// 原告单位获取
export const getPlaintiffCompany = id => {
  let path = PLAINTIFFTCOMPANY_GET_PATH + '/' + id
  return req.get(path)
}
// 原告单位修改
export const putPlaintiffCompany = data => {
  let path = PLAINTIFFTCOMPANY_GET_PATH + '/' + data.id
  return req.put(path, data)
}

const CHARGEVOUCHER_POST_PATH = ZHPQ_SERVER + '/caseChargeVoucher/' // 收费凭证

// 收费凭证 添加
export const postChargeVoucher = data => {
  return req.post(CHARGEVOUCHER_POST_PATH, data)
}
// 收费凭证 修改
export const putChargeVoucher = data => {
  let path = CHARGEVOUCHER_POST_PATH + data.id
  return req.put(path, data)
}
// 收费凭证删除
export const delChargeVoucher = id => {
  let path = CHARGEVOUCHER_POST_PATH + id
  return req.delete(path)
}

const ACCEPTAPPROVAL_POST_PATH = ZHPQ_SERVER + '/caseAcceptApproval/' // 收案审批表
const USERLIST_GET_PATH = ZHPQ_SERVER + '/user/list?type=01' // 受理律师list

// 律师 list
export const getUserList = _ => {
  return req.get(USERLIST_GET_PATH)
}
// 收案审批表 添加
export const postAcceptApproval = data => {
  return req.post(ACCEPTAPPROVAL_POST_PATH, data)
}
// 收案审批删除
export const delAcceptApproval = id => {
  let path = ACCEPTAPPROVAL_POST_PATH + id
  return req.delete(path)
}

const AGENTSWORD_POST_PATH = ZHPQ_SERVER + '/caseAgentsWord/' // 代理词
const ENTRUSTLETTER_POST_PATH = ZHPQ_SERVER + '/caseEntrustLetter/' // 委托书
const INDICTMENT_POST_PATH = ZHPQ_SERVER + '/caseIndictment/' // 起诉书
const EVIDENCE_POST_PATH = ZHPQ_SERVER + '/caseEvidence/' // 证据材料

// 代理词 添加
export const postAgentsWord = data => {
  return req.post(AGENTSWORD_POST_PATH, data)
}
// 代理词删除
export const delAgentsWord = id => {
  let path = AGENTSWORD_POST_PATH + id
  return req.delete(path)
}
// 委托书 添加
export const postEntrustLetter = data => {
  return req.post(ENTRUSTLETTER_POST_PATH, data)
}
// 委托书删除
export const delEntrustLetter = id => {
  let path = ENTRUSTLETTER_POST_PATH + id
  return req.delete(path)
}
// 起诉书 添加
export const postIndictment = data => {
  return req.post(INDICTMENT_POST_PATH, data)
}
// 起诉书删除
export const delIndictment = id => {
  let path = INDICTMENT_POST_PATH + id
  return req.delete(path)
}
// 证据材料 添加
export const postEvidence = data => {
  return req.post(EVIDENCE_POST_PATH, data)
}
// 证据材料删除
export const delEvidence = id => {
  let path = EVIDENCE_POST_PATH + id
  return req.delete(path)
}

const PLEADINGS_POST_PATH = ZHPQ_SERVER + '/casePleadings/' // 答辩状
const TRIALRECORD_POST_PATH = ZHPQ_SERVER + '/caseTrialRecord/' // 庭审笔录
const JUDGMENT_POST_PATH = ZHPQ_SERVER + '/caseJudgment/' // 判决书 裁定书 调解书

// 答辩状 添加
export const postPleadings = data => {
  return req.post(PLEADINGS_POST_PATH, data)
}
// 答辩状删除
export const dePleadings = id => {
  let path = PLEADINGS_POST_PATH + id
  return req.delete(path)
}
// 庭审笔录 添加
export const postTrialRecord = data => {
  return req.post(TRIALRECORD_POST_PATH, data)
}
// 庭审笔录删除
export const delTrialRecord = id => {
  let path = TRIALRECORD_POST_PATH + id
  return req.delete(path)
}
// 判决书 添加
export const postJudgment = data => {
  return req.post(JUDGMENT_POST_PATH, data)
}
// 判决书删除
export const delJudgment = id => {
  let path = JUDGMENT_POST_PATH + id
  return req.delete(path)
}

const LAWCOURT_LIST_PATH = ZHPQ_SERVER + '/lawCourt/list' // 受理单位
const LAWJUDGE_LIST_PATH = ZHPQ_SERVER + '/lawJudge/list' // 承办人
const ENDSUMMARY_PATH = ZHPQ_SERVER + '/caseEndSummary/' // 办案小结

// 受理单位 list
export const getLawCourtList = _ => {
  return req.get(LAWCOURT_LIST_PATH)
}

// 承办人 list
export const getLawJudgeList = courtId => {
  if (typeof courtId === 'undefined') return req.get(LAWJUDGE_LIST_PATH)
  let path = LAWJUDGE_LIST_PATH + '?courtId=' + courtId
  return req.get(path)
}

// 办案小结
export const postEndSummary = data => {
  return req.post(ENDSUMMARY_PATH, data)
}

// 服务记录
const SERVICELOG_PATH = ZHPQ_SERVER + '/caseServiceLog'

export const postServiceLog = data => {
  let path = SERVICELOG_PATH + '/'
  return req.post(path, data)
}
export const getServiceLog = data => {
  return req.get(SERVICELOG_PATH, data)
}
export const getServiceLogDetail = id => {
  let path = SERVICELOG_PATH + '/' + id
  return req.get(path)
}
export const putServiceLog = data => {
  let path = SERVICELOG_PATH + '/' + data.id
  return req.put(path, data)
}
export const delServiceLog = id => {
  let path = SERVICELOG_PATH + '/' + id
  return req.delete(path)
}

const CHECKCUSTOMER_PATH = ZHPQ_SERVER + '/lawCase/listCaseRelated' // 检测

export const checkCustomerReq = name => {
  let path = CHECKCUSTOMER_PATH + '?name=' + name
  return req.get(path)
}
